package com.pussinboots.morning.sync.controller;

import com.pussinboots.morning.sync.dao.BuffProductMapper;
import com.pussinboots.morning.sync.entity.BuffProduct;
import com.pussinboots.morning.sync.service.IBuffProductService;
import com.pussinboots.morning.sync.service.ISyncService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sync")
@CommonsLog
public class BuffProductController {

    @Autowired
    private IBuffProductService buffProductService;
    @Autowired
    private ISyncService syncService;

    @Autowired
    private BuffProductMapper buffProductMapper;

    @GetMapping("/list")
    public String getProducts(){
        buffProductService.sync();
        return "success";
    }

    @GetMapping("/order")
    public String orderSync(){
        log.info("info");
        log.error("error");
        log.warn("warn");
        syncService.syncOrder();
        return "order";
    }

    @GetMapping("/product")
    public String productSync(){
        syncService.syncStockOrProduct(true);
        return "product";
    }

    @GetMapping("/stock")
    public String stockSync(){
        syncService.syncStockOrProduct(false);
        return "stock";
    }
}
